#ifndef MACRO_H
#define MACRO_H

#define FALSE           0
#define TRUE            (!FALSE)
#define NULL            ((void *) 0)
#define is_digit(c)     ((c) >= '0' && (c) <= '9')
#define disable_irqs()  __asm__ __volatile__("cli": : :"memory")
#define enable_irqs()   __asm__ __volatile__("sti": : :"memory")
#define idle_moment()   __asm__ __volatile__("rep; nop")
#define LengthOf(x)     (sizeof(x) / sizeof(x[1]))
#define min(a,b)        ((a) < (b) ? (a) : (b))
#define max(a,b)        ((a) > (b) ? (a) : (b))
#define CHECK_FLAG(flags,bit)   ((flags) & (1 << (bit)))

// napalm's code
#define io_readb(addr)      (*(volatile unsigned char *)  (addr))
#define io_readw(addr)      (*(volatile unsigned short *) (addr))
#define io_readl(addr)      (*(volatile unsigned int *)   (addr))
#define io_writeb(addr, b)  (*(volatile unsigned char *)  (addr) = (b))
#define io_writew(addr, b)  (*(volatile unsigned short *) (addr) = (b))
#define io_writel(addr, b)  (*(volatile unsigned int *)   (addr) = (b))

#endif

